/**
 * 
 */
package org.bean.spiral.processor;


import java.util.Collection;


/**
 * @author zsaiye
 * 
 */
public class ModelBuilder {

  public static <E, T> Collection<T> build(Collection<E> mainCollection) {

    RootBuilder<T> builder = new RootBuilder<T>();
    Resolver resolver = new Resolver();
    T root = null;
    try {

      for (E element : mainCollection) {
        root = builder.buildInstrance(element);
        resolver.process(root, element);
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    return builder.maintainedObjects;
  }
}
